package org.pf.base.pfSystem
{
	import com.demonsters.debugger.MonsterDebugger;
	import flash.display.Sprite;
	import org.pf.base.pfGraphics.staff.PFEmptySprite;
	import org.pf.base.pfSystem.PFSystemControlLayer;
	
	/**
	 * ...
	 * @author zeksa'
	 */
	public class PFSystemLayers extends Sprite
	{
		private var _backgroundLayer:Sprite;
		private var _debugLayer:Sprite;
		private var _viewLayer:Sprite;
		private var _effectsLayer:PFEmptySprite;
		private var _controlLayer:PFSystemControlLayer;
		
		private var gWidth:Number;
		private var gHeight:Number;
		
		public function PFSystemLayers(p_gWidth:Number, p_gHeight:Number)
		{
			gWidth = p_gWidth;
			gHeight = p_gHeight;
			
			name = "systemLayers";
			
			_backgroundLayer = new Sprite();
			_backgroundLayer.name = "backgroundLayer";
			
			_debugLayer = new Sprite();
			_debugLayer.name = "debugLayer";
			
			_viewLayer = new Sprite();
			_viewLayer.name = "viewLayer";
			
			_effectsLayer = new PFEmptySprite();
			_effectsLayer.name = "effectsLayer";
			_effectsLayer.mouseEnabled = false;
			_effectsLayer.mouseChildren = false;
			_controlLayer = new PFSystemControlLayer(p_gWidth, p_gHeight);
			
			addChild(_controlLayer);
			addChild(_backgroundLayer);
			addChild(_debugLayer);
			addChild(_effectsLayer);
			addChild(_viewLayer);
			
			MonsterDebugger.inspect(this);
		}
		
		public function clearLayers():void
		{
			_backgroundLayer.graphics.clear();
			_debugLayer.graphics.clear();
			_viewLayer.graphics.clear();
			_effectsLayer.refresh();
			
			clearControlLayer();
		}
		
		public function revertPositions():void
		{
			_backgroundLayer.x = 0;
			_backgroundLayer.y = 0;
			
			_debugLayer.x = 0;
			_debugLayer.y = 0;
			
			_viewLayer.x = 0;
			_viewLayer.y = 0;
			
			_effectsLayer.x = 0;
			_effectsLayer.y = 0;
			
			_controlLayer.x = 0;
			_controlLayer.y = 0;
		}
		
		public function revertSizes():void
		{
			_backgroundLayer.scaleX = 1;
			_backgroundLayer.scaleY = 1;
			
			_debugLayer.scaleX = 1;
			_debugLayer.scaleY = 1;
			
			_viewLayer.scaleX = 1;
			_viewLayer.scaleY = 1;
			
			_effectsLayer.scaleX = 1;
			_effectsLayer.scaleY = 1;
			
			_controlLayer.scaleX = 1;
			_controlLayer.scaleY = 1;
		}
		
		public function clearControlLayer():void
		{
			_controlLayer.graphics.clear();
			removeChild(_controlLayer);
			_controlLayer = null;
			
			_controlLayer = new PFSystemControlLayer(gWidth, gHeight);
			addChildAt(_controlLayer, 0);
		}
		
		public function set backgroundLayer(value:Sprite):void
		{
			_backgroundLayer = value;
		}
		
		public function get backgroundLayer():Sprite
		{
			return _backgroundLayer;
		}
		
		public function get debugLayer():Sprite
		{
			return _debugLayer;
		}
		
		public function get viewLayer():Sprite
		{
			return _viewLayer;
		}
		
		public function get effectsLayer():Sprite
		{
			return _effectsLayer as Sprite;
		}
		
		public function get controlLayer():PFSystemControlLayer
		{
			return _controlLayer;
		}
	
	}

}